package xinxin.com.ObserverPattern.Subject.Detail;

import xinxin.com.ObserverPattern.Observer.Observer;
import xinxin.com.ObserverPattern.Subject.Subject;

import java.util.ArrayList;
import java.util.List;

public class Boss implements Subject {
    // 同事列表
    private List<Observer> observers = new ArrayList<Observer>();
    private String action;

    // 增加
    public void Attach(Observer observer) {
        observers.add(observer);
    }

    // 减少
    public void Detach(Observer observer) {
        observers.remove(observer);
    }
    // 通知
    public void Notify() {
        for (Observer observer : observers) {
            observer.Update();
        }
    }

    // 老板状态
    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }
}
